package com.jar.exercise.设计模式.cases.url构建案例;

import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;

import java.net.URI;

public class MainTest {

    public static void main(String[] args) {

        final URI build = new DefaultUriBuilderFactory()
                .uriString("https://www.baidu.com")
                .host("www.ailiyun.com")
                .port("8081")
                .userInfo("user")
                .build();
        System.out.println(build.toString());


        final UriComponents build1 = UriComponentsBuilder.fromUriString("https://www.baidu.com:443/search?key=haha")
                .host("alibaba")
                .scheme("http")
                .port(80)
                .queryParam("key", "v1" , "v2")
                .path("hello")
                .build();

        System.out.println(build1.toUriString());

    }

}
